<template>
  <div class="main-layout">
    <aside class="sidebar">
      <div class="logo-area">
        <i class="el-icon-user-solid logo-icon"></i>
        <span class="logo-title">智慧会议管理平台</span>
      </div>
      <el-menu
        class="el-menu-vertical-demo"
        :default-active="activeMenu"
        background-color="#000"
        text-color="#fff"
        active-text-color="#1abc9c"
        router
      >
        <el-menu-item index="/home">
          <el-icon><HomeFilled /></el-icon>
          <span>首页</span>
        </el-menu-item>
        <el-menu-item index="/roomlist">
          <el-icon><OfficeBuilding /></el-icon>
          <span>会议室管理</span>
        </el-menu-item>
        <el-menu-item index="/appiontlist">
          <el-icon><Link /></el-icon>
          <span>会议预约</span>
        </el-menu-item>
        <el-menu-item index="/meetapproval">
          <el-icon><CircleCheckFilled /></el-icon>
          <span>会议审批</span>
        </el-menu-item>
        <el-menu-item index="/analysis">
          <el-icon><DataAnalysis /></el-icon>
          <span>统计分析</span>
        </el-menu-item>
        <el-sub-menu index="system">
          <template #title>
            <el-icon><Setting /></el-icon>
            <span>系统管理</span>
          </template>
          <el-menu-item index="/userlist">用户管理</el-menu-item>
          <el-menu-item index="/rolelist">角色权限</el-menu-item>
          <el-menu-item index="/deptlist">部门管理</el-menu-item>
          <el-menu-item index="/log">操作日志</el-menu-item>
        </el-sub-menu>
      </el-menu>
    </aside>
    <div class="main-content">
      <header class="topbar">
        <i class="el-icon-s-fold topbar-menu">
        </i>
        <el-button type="danger" class="logout-button" @click="Quit">退出</el-button>
      </header>
      <section class="content-area">
        <router-view />
      </section>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
const route = useRoute()
const router = useRouter()
const activeMenu = ref(route.path)
import { ElMessage, ElMessageBox } from 'element-plus'
import { HomeFilled, OfficeBuilding, Link, CircleCheckFilled, DataAnalysis, Setting } from '@element-plus/icons-vue'
const Quit = () => {
  ElMessageBox.confirm(
    '确定退出吗？',
    'Warning',
    {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning',
    }
  )
    .then(() => {
      router.push('/')
    })
}

</script>

<style scoped>
.main-layout {
  display: flex;
  height: 100vh;
}
.sidebar {
  width: 260px;
  background: #000;
  color: #fff;
  display: flex;
  flex-direction: column;
  padding-top: 18px;
}
.logo-area {
  display: flex;
  align-items: center;
  padding: 0 18px 24px 18px;
}
.logo-icon {
  font-size: 32px;
  color: #1abc9c;
  margin-right: 10px;
}
.logo-title {
  font-size: 24px;
  font-weight: bold;
  letter-spacing: 2px;
}
.menu-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.menu-item {
  display: flex;
  align-items: center;
  font-size: 18px;
  padding: 16px 28px;
  cursor: pointer;
  transition: background 0.2s;
  position: relative;
}
.menu-item:hover {
  background: #222;
}
.menu-item i {
  font-size: 20px;
  margin-right: 12px;
}
.menu-parent {
  user-select: none;
}
.arrow {
  margin-left: auto;
  font-size: 14px;
  color: #1abc9c;
  transition: transform 0.2s;
  display: flex;
  align-items: center;
}
.arrow.open {
  transform: rotate(180deg);
}
.submenu-list {
  list-style: none;
  padding: 0 0 0 48px;
  margin: 0;
  background: transparent;
}
.submenu-item {
  font-size: 16px;
  color: #ccc;
  padding: 10px 0 10px 0;
  cursor: pointer;
  transition: color 0.2s;
}
.submenu-item:hover {
  color: #fff;
}
.fade-enter-active, .fade-leave-active {
  transition: all 0.2s;
}
.fade-enter-from, .fade-leave-to {
  opacity: 0;
  max-height: 0;
}
.fade-enter-to, .fade-leave-from {
  opacity: 1;
  max-height: 500px;
}
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #f5f7fa;
}
.topbar {
  height: 48px;
  background: #fff;
  display: flex;
  align-items: center;
  padding: 0 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}
.topbar-menu {
  font-size: 24px;
  color: #333;
  cursor: pointer;
}
.content-area {
  flex: 1;
  padding: 32px;
  background: #f5f7fa;
}
.logout-button {
  margin-left: auto;
}
</style>